function Chromosome = variableNeighborhoodSearch(Chromosome, DSM, params)
    % Performs Variable Neighborhood Search (Merge/Split) - Simplified version
     if isempty(Chromosome); return; end

     currentBestChromo = Chromosome;
     currentBestFitness = calculateFitness(currentBestChromo, DSM);

     k = 1; % Neighborhood index
     while k <= params.VNS_MaxNeighborhoods
          improved = false;
          if k == 1 % Neighborhood 1: Module Merge (Try one random merge)
               if size(currentBestChromo, 1) > 1 % Can only merge if >1 module
                    rows_to_merge = datasample(1:size(currentBestChromo, 1), 2, 'Replace', false);
                    
                    mergedChromo = currentBestChromo;
                    % Combine elements from row2 into row1
                    mergedChromo(rows_to_merge(1), :) = mergedChromo(rows_to_merge(1), :) | mergedChromo(rows_to_merge(2), :);
                    % Remove row2
                    mergedChromo(rows_to_merge(2), :) = []; 
                    
                    % Validate and check fitness
                    if all(sum(mergedChromo, 1) == 1)
                         mergedFitness = calculateFitness(mergedChromo, DSM);
                         if mergedFitness > currentBestFitness
                              currentBestChromo = mergedChromo;
                              currentBestFitness = mergedFitness;
                              k = 1; % Restart search from first neighborhood
                              improved = true;
                              % fprintf('VNS Merge Improvement: %.4f\n', currentBestFitness);
                         end
                    end
               end
          elseif k == 2 % Neighborhood 2: Module Split (Try one random split)
               rows = size(currentBestChromo, 1);
               M = size(currentBestChromo, 2);
               if M > rows % Can only split if elements > modules (guarantees some module > 1)
                    potential_rows_to_split = find(sum(currentBestChromo, 2) > 1);
                    if ~isempty(potential_rows_to_split)
                         row_to_split = datasample(potential_rows_to_split, 1);
                         elements_in_module = find(currentBestChromo(row_to_split, :));
                         
                         % Select N >= 1 elements to move
                         num_to_move = randi(length(elements_in_module)); % Move 1 to all elements
                         elements_to_move = datasample(elements_in_module, num_to_move, 'Replace', false);

                         splitChromo = currentBestChromo;
                         % Create new row (module)
                         new_row = zeros(1, M);
                         new_row(elements_to_move) = 1; 
                         % Remove elements from original row
                         splitChromo(row_to_split, elements_to_move) = 0;
                         % Add the new row
                         splitChromo = [splitChromo; new_row]; %#ok<AGROW>

                         % Validate and check fitness
                         if all(sum(splitChromo, 1) == 1)
                              splitFitness = calculateFitness(splitChromo, DSM);
                              if splitFitness > currentBestFitness
                                   currentBestChromo = splitChromo;
                                   currentBestFitness = splitFitness;
                                   k = 1; % Restart search
                                   improved = true;
                                   % fprintf('VNS Split Improvement: %.4f\n', currentBestFitness);
                              end
                         end
                    end
               end
          end % End if k==1 or k==2
          
          if ~improved
               k = k + 1; % Move to next neighborhood if no improvement found
          end
     end % End while k loop
     
     Chromosome = currentBestChromo; % Return the best found via VNS
end
